import machine
import utime


def get(ADC_IO=4):
    sensor_temp = machine.ADC(ADC_IO)
    reading = sensor_temp.read_u16() * 3.3 / 65535

    # 温度传感器通过第五ADC通道，测量偏置双极二极管的电压
    # 一般情况下，27度下Vbe = 0.706V, 每上升一度-1.721mV.
    temperature = 27 - (reading - 0.706) / 0.001721
    return temperature


if __name__ == "__main__":
    while 1:
        print('温度：', get())
        utime.sleep(1)

